package com.jiyun.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jiyun.pojo.User;
import com.jiyun.service.UserService;
import common.models.dtos.SmsDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * 登陆
 */
@RestController
@RequestMapping("/shop")
public class UserController {
    @Autowired
    private UserService userService;


    @PostMapping("/login")
    public String login(@RequestBody User user){

        return userService.login(user);
    }

    @PostMapping("/sms")
    public String sms(@RequestBody SmsDto dto){
        boolean sms = userService.sms(dto);
        if (sms){
            return "发送验证码成功";
        }else {
            return "发送验证码失败";
        }
    }

    @PostMapping("/login2")
    public String login3(@RequestBody SmsDto dto){
        boolean smslogin = userService.smslogin(dto);
        if (smslogin){
            return "登陆成功";
        }else {
            return "登陆失败";
        }

    }
}
